﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

namespace PhuLeBooze.Global
{
    public class CCookies : CHttpContext
    {
        #region "Public Property"
        #endregion

        #region "Static Method"
        public static string GetCookies(string key)
        {
            HttpCookie cookie = Request.Cookies[key];
            if (cookie != null)
            {
                return cookie.Value.ToString();
            }
            else
            {
                return null;
            }
        }
        public static void SetCookies(string key, string value)
        {
            HttpCookie cookies = new HttpCookie(key);
            cookies.Value = value;
            cookies.Expires = DateTime.Now + new TimeSpan(24, 0, 0);
            Response.Cookies.Add(cookies);
        }
        public static void SetCookies(string key, string value, DateTime expiredTime)
        {
            HttpCookie cookies = new HttpCookie(key);
            cookies.Value = value;
            cookies.Expires = expiredTime;
            Response.Cookies.Add(cookies);
        }
        public static void DeleteCookies(string key)
        {
            if (HttpContext.Current.Request.Cookies[key] != null)
                HttpContext.Current.Response.Cookies[key].Expires = DateTime.Now.AddDays(-10);
        }
        #endregion
    }
}
